//
//  BaseListTableview.m
//  住房条件帅选器
//
//  Created by MB__Lee on 2018/5/17.
//  Copyright © 2018年 MB__Lee. All rights reserved.
//

#import "BaseListTableview.h"
#import "BaseHouseListCell.h"

@interface BaseListTableview()<UITableViewDelegate,UITableViewDataSource>



@end

static NSString *BaseHouseListCell_Identi = @"BaseHouseListCell";
@implementation BaseListTableview

-(NSMutableArray *)BaseHouseMut{
    if (!_BaseHouseMut) {
        _BaseHouseMut = [NSMutableArray array];
    }
    return _BaseHouseMut;
}

-(instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style{
    if (self =[super initWithFrame:frame style:style]) {
        self.delegate = self;
        self.dataSource = self;
        
        self.separatorStyle = UITableViewCellSeparatorStyleNone;
        
        [self registerNib:[UINib nibWithNibName:BaseHouseListCell_Identi bundle:nil] forCellReuseIdentifier:BaseHouseListCell_Identi];
        
    }
    return self;
}
-(NSInteger)numberOfSections{
    return  1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return  self.BaseHouseMut.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    BaseHouseListCell *cell = [tableView dequeueReusableCellWithIdentifier:BaseHouseListCell_Identi];
    cell.selectionStyle = UITableViewCellSeparatorStyleNone;
    
    if (self.BaseHouseMut.count) {
      cell.model = self.BaseHouseMut[indexPath.row];
    }
    
    return  cell;
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return  118;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    BaseHouseModel *model = self.BaseHouseMut[indexPath.row];
    
    if (_snBlock) {
        _snBlock(model.sn);
    }
}


#pragma mark ---添加数据
-(void)addSource:(NSMutableArray *)sourceArray{
    [self.BaseHouseMut addObjectsFromArray:sourceArray];
    [self reloadData];
}



@end
